package java1206;

import java.util.ArrayList;
import java.util.List;

class Person{

}
class Student extends Person{

}
public class Test1206 {
    public static void main1(String[] args) {
        ArrayList<Student> arrayList = new ArrayList<>();
        List<Person> list = new ArrayList<>(arrayList);
        //ArrayList传输的变量类型，只能是Person或Person的子类
    }
    //ArrayList
    public static void main(String[] args) {
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("abc");
        arrayList.add("def");
        List<String> list = new ArrayList<>(arrayList);
        ArrayList<Integer> arrayList1 = new ArrayList<>();
        //ArrayList<String> arrayList2 = new ArrayList<>(arrayList1 );
        //因为ArrayList<>传输的arrayList1类型不是String或String的子类，而是Integer，所以会报错
        list.add("hello");
        System.out.println("========");
    }
}
